<%@ page language="java" import="java.util.*,entitybean.oc_sea_area.EntityBeanOc_Sea_Area,entitybean.oc_boat.EntityBeanOc_Boat,view.ViewOc_Sea_Area,tools.PageBeanPlus,form.SeaAreaForm" pageEncoding="utf-8"%>

<%
List<EntityBeanOc_Sea_Area>list_sea_area=(List<EntityBeanOc_Sea_Area>)request.getAttribute("list_sea_area");
List<EntityBeanOc_Boat>list_boat=(List<EntityBeanOc_Boat>)request.getAttribute("list_boat");
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>adminindex</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
<style>
body{
	background-color: #EAEBE3;
}
</style>
<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="dwr/engine.js">
</script>
		<script type="text/javascript" src="dwr/util.js">
</script>
		<script type="text/javascript" src="dwr/interface/voyage.js">
</script>
<script>
function  insert_me()
{
	var ns=document.getElementById("NS").value;
	var ew=document.getElementById("EW").value;
	var longitude=document.getElementById("longitude").value;
	var dimensionality=document.getElementById("dimensionality").value;
	var station_name=document.getElementById("station_name").value;  
	var work_time=document.getElementById("work_time").value; 
	document.getElementById("longitude").value=ew+" "+document.getElementById("longitude").value;
	document.getElementById("dimensionality").value=ns+" "+document.getElementById("dimensionality").value;
	var depth=document.getElementById("depth").value;
	var oc_voyage_id=document.getElementById("oc_voyage_id").value;
	if(station_name=="")
	{
		window.alert("站点名称不得为空!");
		return false;
	}
	if(depth=="")
	{
		window.alert("站点深度不得为空!");
		return false;
	}
	if(longitude=="")
	{
		window.alert("经度不得为空!");
		return false;
	}
	if(dimensionality=="")
	{
		window.alert("维度不得为空!");
		return false;
	}
	if(isNaN(depth)){
       window.alert("站点深度必须是数字");
       return false;
    }
	if(work_time=="")
	{
		window.alert("操作不得为空!");
		return false;
	}
	if(oc_voyage_id=="")
	{
		window.alert("航次不得为空!");
		return false;
	}
	
	//EW
	//longitude
	//dimensionality
	var url="<%=request.getContextPath()%>/admin_insert_station.do?method=admin_insert_oc_station&v="+Math.random();
	document.getElementById("form1").action=url;
    document.getElementById("form1").submit();
}



function load_voyage() {
	var id = document.getElementById("oc_boat_id").value;
	//window.alert(id);
	if (id != -1) {

		voyage.Ajax_voyage_load(id, checkerA);
	} else {
		for (k = document.getElementById("oc_voyage_id").children.length - 1; k >= 0; k--) {
			//remove all
			document.getElementById("oc_voyage_id").removeChild(
					document.getElementById("oc_voyage_id").children(0));
		}
		var varItem = new Option("请选择", -1);
		document.getElementById("oc_voyage_id").add(varItem);
	}
}

function checkerA(str) {
	for (k = document.getElementById("oc_voyage_id").children.length - 1; k >= 0; k--) {
		//remove all
		document.getElementById("oc_voyage_id").removeChild(
				document.getElementById

				("oc_voyage_id").children(0));
	}
	var varItem = new Option("请选择", -1);
	document.getElementById("oc_voyage_id").add(varItem);
	strword = str;
	while (strword.indexOf(",") > 0) {
		var key = cut_word(strword, ",");
		var val = cut_word(strword, ",");
		var varItem = new Option(val, key);
		document.getElementById("oc_voyage_id").add(varItem);
	}
}
function cut_word(str, keyword) {
	var i = str.indexOf(keyword);
	var backword = str.substring(0, i);
	strword = str.substring(i + 1);
	return backword
}
</script>
</head>
<body>


<div class="admin_nei">


<div class="xge">
  <!--<div class="xgetitle"><img src="../../images/admin_38.jpg" alt="" /></div> -->
  <div class="gt">
    
    
    
    <div class="gtt">
    <form id="form1" name="form1" method="post" action="">
   <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a0a297">
     <tr>
       <td bgcolor="#eaebe3">站位添加</td>
       </tr>
   </table>
   <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#E6E6E6" id="admintxt">
     <tr>
       <td width="25%" align="right" bgcolor="#FFFFFF">站点名称：</td>
       <td width="25%" bgcolor="#FFFFFF"><input type="text" name="station_name" id="station_name" /></td>
       <td width="25%" align="right" bgcolor="#FFFFFF">所属海域</td>
       <td width="25%" bgcolor="#FFFFFF">
       <select name="territorial_waters" id="territorial_waters">
       <%for(int i=0;i<list_sea_area.size();i++){ %>
       <option value="<%=list_sea_area.get(i).getId() %>"><%=list_sea_area.get(i).getOc_sea_area() %></option>
       <%} %>
       
       </select></td>
       </tr>
     <tr>
       <td align="right" bgcolor="#FFFFFF">CTD操作</td>
       <td bgcolor="#FFFFFF"><select name="ctd" id="ctd">
         <option value="YES">YES</option>
         <option value="NO">NO</option>
       </select></td>
       <td bgcolor="#FFFFFF" align="right">所属航次</td>
       <td bgcolor="#FFFFFF">科考船
         <select name="oc_boat_id" id="oc_boat_id" onchange="load_voyage()">
        <%for(int i=0;i<list_boat.size();i++){ %>
         <option value="<%=list_boat.get(i).getId() %>"><%=list_boat.get(i).getOc_boatname() %></option>
         <%} %>
       </select>
         航次
         <select name="oc_voyage_id" id="oc_voyage_id">
           <option value="">请选择</option>
         </select></td>
     </tr>
     <tr>
       <td align="right" bgcolor="#FFFFFF">经度：</td>
       <td bgcolor="#FFFFFF"><select name="EW" id="EW">
         <option value="E">东经</option>
         <option value="W">西经</option>
       </select>         
         <input type="text" name="longitude" id="longitude" /></td>
       <td bgcolor="#FFFFFF" align="right">维度</td>
       <td bgcolor="#FFFFFF"><select name="NS" id="NS">
         <option value="N">北纬</option>
         <option value="S">南纬</option>
       </select>         
         <input type="text" name="dimensionality" id="dimensionality" /></td>
     </tr>
     <tr>
       <td align="right" bgcolor="#FFFFFF">操作时间</td>
       <td bgcolor="#FFFFFF"><input type="text" name="work_time" id="work_time" onClick="WdatePicker()" readonly/></td>
       <td bgcolor="#FFFFFF" align="right">站点深度</td>
       <td bgcolor="#FFFFFF"><input type="text" name="depth" id="depth" /></td>
     </tr>
     <tr>
       <td bgcolor="#FFFFFF">&nbsp;</td>
       <td colspan="3" bgcolor="#FFFFFF"><input type="button" name="button" id="button"  value=" 提交 " onclick="insert_me()"/></td>
     </tr>
   </table>
    </form>
 </div>
    
    
    
    
    </div>
  
</div>
</div>







</body>
</html>
